//
//  Animator.m
//  BeautyBaoUnion
//
//  Created by 肖智 on 2016/10/25.
//  Copyright © 2016年 肖智. All rights reserved.
//

#import "Animator.h"

@implementation Animator
- (instancetype)init{
    self = [super init];
    if(self){
        [self defaultSetting];
    }
    return self;
}
- (void)defaultSetting{
    _index = 0;
    _transform = CATransform3DIdentity;
    _minScaleFactor = 0.03;
    _minDistanceY = 5.0;
    _size = CGSizeZero;
}
- (void)setTransform:(CATransform3D)transform{
    _transform = transform;
}
- (void)setSize:(CGSize)size{
    _size = size;
}
- (void)setIndex:(NSInteger)index{
    _index = index;
    _transform = CATransform3DIdentity;
    CGFloat scale = _minScaleFactor*index;
    _transform = CATransform3DScale(_transform, 1-scale, 1-scale, 1.0);
    CGFloat translateY = scale*_size.height/2.0+(index*_minDistanceY);
    _transform = CATransform3DTranslate(_transform, 0, translateY/(1-scale), 0);
}
@end
